cwinthread class is a virtual function based on the polymorphism principle, initinstance () in the subclass ctestapp is called here ()
Pthread-> Run () to complete the message loop
Where
After pthread-> initinstance () initialization is complete, the registration window starts.
Cwinapp in appcore. cpp -- Global Object theapp -- subclass constructor call ctestapp () -- base class constructor call cwinapp () in appcore. cpp
-- _ Twinmain () in appmodul. cpp -- pthread-> initinstance () in afxwi
, the system will call the csuperedit: onchar function (instead of the original cedit: onchar function) That I wrote myself)
Implementation of superclassAll the secrets are in cwnd: subclasswindow. Let's check what it actually does. The following is the function body (in the wincore. cpp file ):Bool cwnd: subclasswindow (hwnd){If (! Attach (hwnd ))Return false;
// Allow any other subclassing to occurPresubclasswindow ();
// Now hook into the afx wndp
is in the thrdcore. cpp file.The p77 afxgetapp () function is located in afxwin1.inl.The afxcurrentwinapp macro is defined in the afxwin. h file.1. Design a window classP78 MFC has predefined some default standard window classes for us. You only need to select the required window class and then register the window class. Therefore, you do not need to design the window class.2. register the window classThe registration of the p78 window class is completed by the afxenddeferregisterclass () funct
the original cedit: onchar function) That I wrote myself)
Ii. Overview of superclassAll the secrets are in cwnd: subclasswindow. Let's check what it actually does. The following is the function body (in the wincore. cpp file ):Bool cwnd: subclasswindow (hwnd){If (! Attach (hwnd ))Return false;
// Allow any other subclassing to occurPresubclasswindow ();
// Now hook into the afx wndprocWndproc * lplpfn = getsuperwndprocaddr ();Wndproc oldwndproc = (wn
), (! (! m_pMainWnd-> m_pMainWnd-> }
In the above Code, m_pMainWnd refers to the window created for us and is defined as a pointer to the CWnd type according to F12. The Cwnd class is a standard window class pre-defined by MFC, now we have found the window class in the MFC program. Next we will find how to register the window in the MFC. In the MFC, the registration of the window class is completed by the Afx
(instead of the original cedit: onchar function) That I wrote myself)
Ii. Overview of superclassAll the secrets are in cwnd: subclasswindow. Let's check what it actually does. The following is the function body (in the wincore. cpp file ):Bool cwnd: subclasswindow (hwnd){If (! Attach (hwnd ))Return false;
// Allow any other subclassing to occurPresubclasswindow ();
// Now hook into the afx wndprocWndproc * lplpfn = getsuperwndprocaddr ();Wndproc
details about other parameters, refer to msdn or in-depth introduction to MFC). What does it mean to set the window class to null? It means to generate a standard out-of-box window using the built-in air class of MFC. However, our programs generally do not register any window classes! Oh, before the create function generates a window, it will trigger the registration operation of the window class.
Let's dig out what the create function has done first. The create function is defined in winfrm.
Zookeeper
MFC message ing mechanism:
In each class that can receive and process messages, define a ing table between messages and message processing functions, that is, the message ing table. MFC has a window handle ing table with the c ++ Object Pointer. When the window receives a message, the first parameter of the message specifies the window handle associated with the message, find the C ++ Object Pointer through the ing table, and pass the pointer to the base class of the window class of
first register a window class and specify window attributes, but which window class is used here? The first parameter of the create function (for details about other parameters, refer to msdn or in-depth introduction to MFC). What does it mean to set the window class to null? It means to generate a standard out-of-box window using the built-in air class of MFC. However, our programs generally do not register any window classes! Oh, before the create function generates a window, it will trigger
-of-box window using the built-in air class of MFC. However, our programs generally do not register any window classes! Oh, before the create function generates a window, it will trigger the registration operation of the window class.
Let's dig out what the create function has done first. The create function is defined in winfrm. THE 538th rows of CPP (here I won't copy the code, you can open it by yourself). The function calls the createex function in line 562, because createex is a member func
generate a standard out-of-box window using the built-in air class of MFC. However, our programs generally do not register any window classes! Oh, before the create function generates a window, it will trigger the registration operation of the window class.Let's dig out what the create function has done first. The create function is defined in winfrm. THE 538th rows of CPP (here I won't copy the code, you can open it by yourself). The function calls the createex function in line 562, because cr
FUNCTION (for details about other parameters, refer to MSDN or in-depth introduction to MFC). What does it mean to set the window class to NULL? It means to generate a standard out-of-box window using the built-in air class of MFC. However, our programs generally do not register any window classes! Oh, before the Create FUNCTION generates a window, it will trigger the registration operation of the window class.
Let's dig out what the Create FUNCTION has done first. The Create function is define
MFC. However, our programs generally do not register any window classes! Oh, before the create function generates a window, it will trigger the registration operation of the window class.
Let's dig out what the create function has done first. The create function is defined in winfrm. THE 538th rows of CPP (here I won't copy the code, you can open it by yourself). The function calls the createex function in line 562, because createex is a member function of cwnd, cframewnd is followed by cwnd, s
disabled before it is passed. This is why the command for the disabled menu item is not called (although not displayed in gray (unavailable )). In this case, the menu item is not re-painted to reflect the status of the menu item. This is the code in the wincore. cpp file:
// Make sure the command is not disabled before the command is passedCtestcmdui state;State. m_nid = NID;On1_msg (NID, cn_update_command_ui, state, null );If (! State. m_benabled){
, execute another program, then only the last function is executed.Nreturncode = pthread-> Run ();This step has become the active source of the program in "getting down to MFC". In my opinion, it is the step for you to drive on the accelerator. We will elaborate on it later!After the design window class, it should be the registration. MFC automatically calls (jumps to) afxenddeferregisterclass (wincore. CPP). Five window classes are registered for you
the cwnd class is the encapsulation of the API function createwindow (), which is encapsulated as the member function create () of the cwnd class (). From the MFC source file wincore. cpp provided by VC, we can clearly see that the cwnd class encapsulates the createwindow () function. The following describes the implementation of the relevant sections:
Bool cwnd: Create (lpctstr lpszclassname, lpctstr lpszwindowname, DWORD dwstyle, cons
------ From http://hi.baidu.com/snownight/blog/item/dc4c0a5522bd24cdb645ae48.html MFC multi-thread programming considerations
[Post] considerations for MFC multi-thread programming Favorites 1. Performance-error exampleAbout the window object (pointer? Handle ?) Problems: After selecting the start thread in the menu:Void cmainframe: onmenu_start (){...Afxbeginthread (mythread, this );...} The thread functions are as follows:Uint mythread (lpvoid pparam){Cmainframe * pmainfrm = (cmain
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.